<%@page import="java.util.ArrayList"%>
<%@page import="bean.CompanyPost"%>
<%@page import="dao.CompanyPostDAO"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-3.1.1/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#input").keyup(function(){
		var name=$("#input").val();
		var industryName=$("#industryName").text();
		$.ajax({
			method:"GET",
			url:"SearchAjaxServlet?partName="+name+"&industryName="+industryName,
			dataType:"json",		
		    success:function(json){
		    	if(json.length>0){
		    		var list="<ul>";
		    		for(var i=0;i<json.length;i++){
		    			list+="<li style='list-style:none'>"+json[i]+"</li>";
		    		}
		    		list+="</ul>"
		    		$("#searchBox").html(list).show();
		    		$("li").click(function(){
		    			$("#input").val($(this).text());
		    			$("#searchBox").hide();
		    		})
		    		//鼠标放上去时
		    		$("li").mouseenter(function(){
		    			$(this).css("background-color","#E9E9E4");
		    		})
		    		//鼠标离开时
		    		$("li").mouseleave(function(){
		    			$(this).css("background-color","white");
		    		})
		    	}
		    	else{
		    		$("#searchBox").hide();
		    	}
		    }
		})
		//输入框失去焦点时
		//$("#input").blur(function(){
		//$("#searchBox").hide();
	    //})
	})
	
})
</script>
<style type="text/css">
h1{
float: left
}
</style>
</head>
<body>
<%
String industryName=(String)request.getAttribute("industryName");
%>
<h1><a href="CompanyServlet">伯企业</a>》》<div id="industryName"><%=industryName %></div></h1>
<table>
<form action="SearchByPostNameServlet">
<tr>
<td>
<input type="hidden" name="industryName" value="<%=industryName%>">
<input id="input" type="text" name="postName">
</td>
<td>
<input type="submit" value="搜索">
</td>
</tr>
<tr>
<td>
<div id="searchBox" style="display: none"></div>
</td>
</tr>
</form>
</table>
<br><br><br><br><br><br>
<hr>
<center>
<%
List<CompanyPost> posts=new ArrayList<CompanyPost>();
Object obj=request.getAttribute("industryPost");
//序号
int index=1;
if(obj!=null){
	posts=(ArrayList<CompanyPost>)obj;
}
if(posts.size()==0){
%>
<b>sorry,该行业没有企业了！</b>
<%
}
else{
%>
<table border="1">
<%
for(CompanyPost cp:posts){
%>
<tr>
<th colspan="2"><%=index%>诚聘<%=cp.getName() %></th>
</tr>
<tr>
<td>企业名称</td>
<td>企业简介</td>
<td>岗位职责和要求</td>
<td>薪资</td>
<td>工作地点</td>
</tr>
<tr>
<td><%=cp.getCompany().getName()%></td>
<td><%=cp.getCompany().getIntroduce()%></td>
<td><%=cp.getRequire()%></td>
<td><%=cp.getSalary() %>k</td>
<td><%=cp.getWorkingSpace()%></td>
</tr>
<%
index++;
}
%>
</table>
<%
}
%>
</center>
</body>
</html>